package com.simple.datax.flow.dao.ibatis.impl;
import java.util.HashMap;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.simple.datax.flow.dao.ibatis.FlowInstanceDao;
import com.simple.datax.flow.dao.ibatis.model.FlowInstance;

public class FlowInstanceDaoImpl extends SqlMapClientDaoSupport implements
		FlowInstanceDao {

	public FlowInstanceDaoImpl() {
		super();
	}
	public void saveFlowInstance(FlowInstance flowInstance) {
		getSqlMapClientTemplate().insert("saveFlowInstance", flowInstance);
	}
	
	@Override
	public FlowInstance getFlowInstance(String taskid) {
		FlowInstance task = null;
		Object obj = getSqlMapClientTemplate().queryForObject(
				"getFlowInstance", taskid);
		if(obj!=null){
			task = (FlowInstance)obj;
		}
		return task;
	}
	
	public void updateFlowInstanceStatus(String taskid,int status) {
		HashMap<String,Object> map = new HashMap<String,Object>();
		map.put("taskid", taskid);
		map.put("status", status);
		getSqlMapClientTemplate().update("updateFlowInstanceStatus",map);
	}
}